package com.lst.projectlib.util;

import android.content.Context;
import android.content.SharedPreferences;

public class Preferences {
    private SharedPreferences mySetting;

    public Preferences(Context context) {
        // mySetting = PreferenceManager.getDefaultSharedPreferences(context);
        // 获得SharedPreferences对象
        mySetting = context.getSharedPreferences("setting",
                Context.MODE_PRIVATE);
    }

    /**
     * 设置用户token
     *
     * @param token
     */
    public void setToken(String token) {
        mySetting.edit().putString("token", token).commit();
    }

    /**
     * 获取用户token
     */
    public String getToken() {
        return mySetting.getString("token", "");
    }

    /**
     * 设置用户exToken
     *
     * @param exToken
     */
    public void setExToken(String exToken) {
        mySetting.edit().putString("exToken", exToken).commit();
    }

    /**
     * 获取用户exToken
     */
    public String getExToken() {
        return mySetting.getString("exToken", "");
    }

    public String getUserName() {
        return mySetting.getString("user_name", "");
    }

    public void setUserName(String userName) {
        mySetting.edit().putString("user_name", userName).commit();
    }

    public int getHoldingCode() {
        return mySetting.getInt("holding_code", 0);
    }

    public void setHoldingCode(int holdingCode) {
        mySetting.edit().putInt("holding_code", holdingCode).commit();
    }
    public String getId() {
        return mySetting.getString("id","");
    }

    public void setId(String id) {
        mySetting.edit().putString("id", id).commit();
    }
    public String getPhone() {
        return mySetting.getString("phone", "");
    }

    public void setPhone(String phone) {
        mySetting.edit().putString("phone", phone).commit();
    }
    public String getLoginPwd() {
        return mySetting.getString("login_pwd", "");
    }

    public void setLoginPwd(String loginPwd) {
        mySetting.edit().putString("login_pwd", loginPwd).commit();
    }
    public String getIsFirst() {
        return mySetting.getString("is_first", "");
    }

    public void setIsFirst(String isFirst) {
        mySetting.edit().putString("is_first", isFirst).commit();
    }
    /**
     * 获取首次安装的版本号
     *
     * @return
     */
    public String getFirstVersion() {
        return mySetting.getString("first_version", "");
    }

    public void setFirstVersion(String Token) {
        mySetting.edit().putString("first_version", Token).commit();
    }
}
